package com.gary.config;

import com.gary.constant.ArchAppHealthCheckConstant;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.Gauge;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
public class AppHealthCheckPrometheusMetricsConfig {

    @Resource
    private PrometheusMeterRegistry prometheusMeterRegistry;

    @Bean("appHealthCheckExporter")
    public Gauge appHealthCheckExporter() {
        return Gauge.build("arch_app_healthcheck","GAUGE 应用健康检查 0.0健康, 1.0不健康")
                .labelNames(ArchAppHealthCheckConstant.TARGET,
                            ArchAppHealthCheckConstant.SERVER_ROOM,
                            ArchAppHealthCheckConstant.CLUSTER,
                            ArchAppHealthCheckConstant.APPLICATION,
                            ArchAppHealthCheckConstant.CHECK_TIME,
                            ArchAppHealthCheckConstant.STATUS)
//                            ArchAppHealthCheckConstant.DETAILS
                .register(prometheusMeterRegistry.getPrometheusRegistry());
    }
}
